package com.shimei.review2.c2;

import com.shimei.review2.objs.JF;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Cainiao1 extends JFrame {
    private JTextArea area;
    private JTextArea area2;
    private JPanel p1;
    private JPanel p2;
    private JPanel p3;
    private JTextField textField;
    private JLabel l1;
    private JLabel l2;
    private JButton button1;
    private JButton button2;

    public Cainiao1() {
        this.setTitle("菜鸟");
        this.setBounds(200, 200, 400, 300);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        p3=new JPanel();

        area = new JTextArea("欢迎来到菜鸟管理系统");
        p3.add(area, BorderLayout.NORTH);

        p1 = new JPanel();
        p1.setLayout(new GridLayout(3, 1));
        l1 = new JLabel("1.登录系统");
        l2 = new JLabel("2.退出系统");
        textField = new JTextField(30);
        p1.add(l1);
        p1.add(l2);
        p1.add(textField);
        p3.add(p1);

        p2 = new JPanel();
        button1 = new JButton("确认");
        button2 = new JButton("取消");
        p2.add(button1);
        p2.add(button2);
        p3.add(p2, BorderLayout.SOUTH);

        this.add(p3);



        button1.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
               if (textField.getText().equals("1")){
                   Cainiao2 cainiao2=new Cainiao2();
                   dispose();
               }else if(textField.getText().equals("2")){
                   JOptionPane.showMessageDialog(null,"即将退出~~~");
                   System.exit(1);
               }
            }
        });
        this.setVisible(true);


    }

    public static void main(String[] args) {
        Cainiao1 cainiao1 = new Cainiao1();
        System.out.println("花式猪\n问君能有几多愁，恰似一江春水向东流");
    }



}
